import count from '@dfeidao/atom-nodejs/db/count';
// import { systemid } from './config';

interface Message {
	productid: string;
	role_no: string;
}

export default async function atom(msg: Message, action_id: string, session_id: string, spaceid: string) {
	const systemid = '12';

	const productid = msg.productid;
	const role_no = msg.role_no;
	let num = 0;
	const c = count(action_id, session_id, systemid);
	c.prepare('pub_user_connect', { productid, role_no });
	const [t] = await c.exec();

	c.prepare('pub_role_allot', { productid, role_no });
	const [t1] = await c.exec();
	if (t !== 0 || t1 !== 0) {
		num = 1;
	}
	return num;
}
